package rozetka.pageObjects;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class HomePage {

	WebDriver driver;
	private static final By usersignUpMenu = By
			.xpath("//*[@id='user_menu']/div/a");
	private static final By fieldForSearch = By
			.xpath("//*[@id='body-header']/div[2]/div/div/div/div[2]/form/div[2]/div[1]/input");
	private static final By searchButton = By
			.xpath("//*[@id='body-header']/div[2]/div/div/div/div[2]/form/div[1]/span/button");

	public HomePage(WebDriver webDriver) {
		this.driver = webDriver;
	}

	public LoginForm showLoginForm() {
		driver.findElement(usersignUpMenu).click();
		return new LoginForm(driver);
	}

	public MenuItemView showMenuItem(String byPath) {
		WebElement usersignUpMenu = driver.findElement(By.xpath(byPath));
		usersignUpMenu.click();
		return new MenuItemView(driver);
	}

	public SearchResultView searchProduct(String productForSearch) {
		driver.findElement(fieldForSearch).sendKeys(productForSearch);
		driver.findElement(searchButton).submit();
		return new SearchResultView(driver);

	}

}
